package com.andbase.demo.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

import com.andbase.demo.R;
import com.andbase.demo.adapter.CalendarListAdapter;
import com.andbase.library.app.base.AbBaseActivity;
import com.andbase.library.view.recycler.AbRecyclerView;

import java.util.ArrayList;


public class CalendarActivity extends AbBaseActivity {

    AbRecyclerView calendarRecyclerView;
    ArrayList<String> calendarList;
    CalendarListAdapter calendarListAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calendar);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        initToolbar(toolbar,"日历",true);

        calendarRecyclerView = (AbRecyclerView)this.findViewById(R.id.calendar_recycler_list);
        calendarList = new ArrayList<>();
        calendarRecyclerView.setNestedScrollingEnabled(false);
        calendarRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        calendarListAdapter = new CalendarListAdapter(this,calendarList);
        calendarRecyclerView.setRecyclerViewAdapter(calendarListAdapter);

        calendarList.add("2019-01");
        calendarList.add("2019-02");
        calendarList.add("2019-03");
        calendarList.add("2019-04");
        calendarList.add("2019-05");
        calendarList.add("2019-06");
        calendarList.add("2019-07");
        calendarListAdapter.notifyDataSetChanged();


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == android.R.id.home) {
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
